package com.hll.spring_book.controller;

import com.hll.spring_book.pojo.Log;
import com.hll.spring_book.service.log.LogService;
import com.hll.spring_book.util.SessionHelper;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author: Mr.Hu
 * @create: 2021-04-20 22:51
 */
@RequestMapping("/log")
@RestController
public class LogController {
  @Resource private LogService logService;

  @PostMapping("personalOPLogs")
  public List<Log> queryLogs(HttpServletRequest request) {
    Log log = new Log();
    log.setAdminId(SessionHelper.getUser().getId());
    return logService.queryAll(log);
  }

  @PostMapping("allLogs")
  public List<Log> queryAllLogs() {
    return logService.queryAll(new Log());
  }
}
